using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vItemInvoiceMap : EntityTypeConfiguration<vItemInvoice>
    {
        public vItemInvoiceMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Invoice_, t.ITEM, t.DATE, t.Store, t.SALESMAN, t.POSTED, t.Currency, t.DOCTYPE });

            // Properties
            this.Property(t => t.Invoice_)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Customer)
                .HasMaxLength(35);

            this.Property(t => t.Register)
                .HasMaxLength(30);

            this.Property(t => t.Store)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.SALESMAN)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Currency)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.DOCTYPE)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("vItemInvoices");
            this.Property(t => t.Invoice_).HasColumnName("Invoice#");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.Qty).HasColumnName("Qty");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.ItemDisount).HasColumnName("ItemDisount");
            this.Property(t => t.ItemTotalAfterDiscount).HasColumnName("ItemTotalAfterDiscount");
            this.Property(t => t.Customer).HasColumnName("Customer");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.Register).HasColumnName("Register");
            this.Property(t => t.Store).HasColumnName("Store");
            this.Property(t => t.SALESMAN).HasColumnName("SALESMAN");
            this.Property(t => t.Closed).HasColumnName("Closed");
            this.Property(t => t.POSTED).HasColumnName("POSTED");
            this.Property(t => t.Total).HasColumnName("Total");
            this.Property(t => t.Discount).HasColumnName("Discount");
            this.Property(t => t.TotalAfterDisc).HasColumnName("TotalAfterDisc");
            this.Property(t => t.Currency).HasColumnName("Currency");
            this.Property(t => t.DOCTYPE).HasColumnName("DOCTYPE");
        }
    }
}
